package com.hanyxx.thread;

/**
 * 测试锁重入以及父子继承
 * @author layman
 * @date 2021/2/5
 */
public class Demo08 {
    public static void main(String[] args) {
        new Demo08Thread().start();
    }
}
class Demo08Service{
    public synchronized  void methodA() {
        System.out.println("methodA方法执行了");
        methodB();
    }
    public synchronized  void methodB() {
        System.out.println("methodB方法执行了");
        methodC();
    }
    public synchronized  void methodC() {
        System.out.println("methodC方法执行了");
    }
}
class Demo08ServiceA extends Demo08Service{
    public synchronized  void methodD() {
        System.out.println("methodD方法执行了");
        methodA();
    }
}
class Demo08Thread extends  Thread{
    @Override
    public void run() {
        /*Demo08Service service = new Demo08Service();
        service.methodA();*/
        Demo08ServiceA service = new Demo08ServiceA();
        service.methodD();
    }
}